home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_shs_power.cog < prev    next >
Text File  |  1999-11-15  |  13KB  |  488 lines

  1. # Jones 3D Cog Script
  2. #
  3. # shs_Power.cog     Power up the clock.  
  4. #
  5. # [JWC] [PKM]
  6. #
  7. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ========================================================================================
  10.  
  11. symbols
  12.  
  13. message startup
  14. message entered
  15. message exited
  16. message crossed
  17. message callback
  18. message touched
  19.  
  20.  
  21. sound         music0=mus_gen_indy_B_motif1.wav        local
  22. sound       powerinit=shs_power_init.wav            local
  23. sound       lowerOn=nub_weight_move_c.wav             local
  24. sound       upperOn=shs_clock_gears.wav              local
  25. sound       gearClunk1=shs_gear_clunk1.wav          local
  26. sound       strain=nub_bull_move3_c.wav                local
  27. sound         music1=mus_aet_pocket_riv.wav             local
  28.  
  29. surface        power_on    mask=0x080        
  30. surface        power_off    mask=0x080
  31.  
  32. surface        gearEngaged    mask=0x080    linkid=1    # faces block can be on
  33. surface        blockface0  mask=0x080    linkid=1
  34. surface        blockface1  mask=0x080    linkid=1
  35.  
  36. surface        entry
  37. surface        inRange
  38. surface       outRange
  39.  
  40. keyframe    clock_houra_k
  41. keyframe    clock_hourb_k
  42. keyframe    clock_mnut_k
  43. keyframe    gearBlock_k
  44. keyframe    clock_star_k
  45. keyframe     clock_axel_k
  46. keyframe    clock_armb_k
  47. keyframe    clock_armt_k
  48. keyframe    clock_leverb_k
  49. keyframe     clock_leverm_k
  50. keyframe    clock_levert_k
  51. keyframe    clock_padb_k
  52. keyframe    clock_padt_k
  53. keyframe    clock_wheelb_k
  54. keyframe    clock_wheelt_k
  55. keyframe    gear_tick_k
  56.  
  57. keyframe    clock_gearsb_k=shs_clock_gearsb.key        local
  58. keyframe    clock_gearsbr_k=shs_clock_gearsbr.key    local
  59. keyframe    clock_axelb_k=shs_clock_axelb.key        local
  60. keyframe    clock_axelbr_k=shs_clock_axelbr.key        local
  61.  
  62. thing    clock_houra
  63. thing    clock_hourb
  64. thing    clock_mnut
  65. thing    clock_star
  66. thing    clock_axel
  67. thing    clock_armb
  68. thing    clock_armt
  69. thing    clock_blockb
  70. thing    clock_wheelb
  71. thing    clock_wheelt
  72. thing    clock_padb
  73. thing    clock_padt
  74. thing    clock_leverb
  75. thing    clock_leverm
  76. thing    clock_levert
  77. thing    clock_gearsb
  78.  
  79. thing    gearBlock
  80.  
  81.  
  82. thing    axelPos0
  83. thing    axelPos1
  84. thing    musicledge
  85.  
  86. thing    clock_padb_ghost
  87. thing    clock_padt_ghost
  88. thing    player                    local
  89.  
  90. # camera stuff
  91. thing    cam1spot                nolink
  92. thing    cam1look                nolink
  93. thing    offsetcam                  nolink
  94. thing    offsettarg               nolink
  95.  
  96. flex    viewangle                local
  97.  
  98. int        clock_houra_track        local
  99. int        clock_hourb_track        local
  100. int        clock_mnut_track        local
  101. int        gearBlock_track            local
  102. int        clock_star_track        local
  103. int        clock_axel_track        local
  104. int        clock_axelb_track        local
  105. int        clock_armb_track        local
  106. int        clock_armt_track        local
  107. int        clock_blockb_track        local
  108. int        clock_blockt_track        local
  109. int        clock_wheelb_track        local
  110. int        clock_wheelt_track        local
  111. int        clock_padb_track        local
  112. int        clock_padt_track        local
  113. int        clock_leverb_track        local
  114. int        clock_leverm_track        local
  115. int        clock_levert_track        local
  116. int        clock_gearsb_track        local
  117. #int        gearTick_track            local
  118. int        played=0                local    # tracks music upon exiting
  119. int        played1=0                local    # tracks music upon entrance
  120.  
  121. int        bPowerIsOn=0            local
  122. int        bGearBlockInPlace=0        local
  123. int        oldCollideType            local
  124. int        oldMoveSize                local
  125. int     curcam                    local
  126.  
  127. int        upperloop=-1            local
  128. int        upperloop1                local    # gearBlock
  129. int        upperloop2                local    # gearTick
  130. int        lowerloop=-1            local
  131. int        lowerloop1=-1            local    # clock_leverm
  132.  
  133. int        upstairsStateStopped=0    local
  134. int        upstairsStateRunning=1    local
  135. int        upstairsStateStarting=2    local
  136. int        upstairsStateStopping=3    local
  137. int        upstairsAnimState=0        local
  138.  
  139. vector    tempPos                    local
  140.   
  141. cog        clockCog
  142.  
  143. # SUBROUTINES
  144.  
  145. flex    startdownstairsanim        local
  146. flex    stopdownstairsanim        local
  147. flex    pausedownstairsanim        local
  148. flex    resumedownstairsanim    local    
  149. flex    startupstairsanim        local
  150. flex    stopupstairsanim        local
  151. flex    returncontrol            local
  152. flex    camera                    local
  153.  
  154.  
  155. end
  156.                                                         
  157. # ========================================================================================
  158.  
  159. code
  160.  
  161. startup:
  162.     call startDownstairsAnim;
  163.     call pauseDownstairsAnim;
  164.     player = GetLocalPlayerThing();
  165.     #SetThingLight(gearTick, '0.3 0.3 0.4', 0.01, 0.1);
  166.     SetThingLight(musicledge, '0.2 0.2 0.2', 0.01, 0.01);
  167.     
  168.     clock_houra_track    = -1;
  169.     clock_hourb_track    = -1;
  170.     clock_mnut_track    = -1;
  171.     gearBlock_track        = -1;
  172.  
  173.     return;
  174.      
  175. crossed:
  176.     
  177.     # music entering power room
  178.     if ((GetSenderRef() == entry) && (played1 == 0))
  179.     {
  180.         PlaySoundLocal(music1, .5, 0, 0x0000, 0);
  181.         played1=1;
  182.     }
  183.     
  184.     if ((GetSenderRef() == outRange) && (Global3 == 1))
  185.     {
  186.         if (upperLoop != -1)
  187.             StopSound(upperloop, 1.0);   
  188.         upperLoop = -1;
  189.     }
  190.  
  191.     if ((GetSenderRef() == inRange) && (bPowerIsOn == 1))   
  192.     {        
  193.         if (upperloop == -1)
  194.             upperloop = PlaySoundThing(upperOn, clock_wheelt, 1, 2, 10, 0x881);
  195.     }
  196.     return;
  197.  
  198. entered:
  199.     
  200.     # check if face has been entered
  201.     if (GetSourceRef() == clock_blockb)
  202.     {
  203.         if (GetSenderRef() == power_on)
  204.         {
  205.             bPowerIsOn = 1;
  206.  
  207.             oldCollidetype = GetCollideType(clock_axel);
  208.             SetCollideType(clock_axel, 0);
  209.             StopKey(clock_axel, clock_axelb_track, 0);
  210.             TeleportThing(clock_axel, axelPos1);
  211.             SetCollideType(clock_axel, oldCollidetype);
  212.  
  213.             call resumeDownstairsAnim;
  214.             call returncontrol;
  215.             
  216.             # check to see if upstairs block is already in place
  217.             if (bGearBlockinPlace == 1)
  218.             {
  219.                 upstairsAnimState = upstairsStateStarting;
  220.             }
  221.         }
  222.     }
  223.     
  224.     # is the block moving on to a face? 
  225.     if ((GetSenderId() == 1) && (GetSourceRef() == gearBlock))
  226.     {
  227.                 
  228.         # is the block on the trigger?
  229.         if (GetSenderRef() == gearEngaged)
  230.         {
  231.             bGearBlockInPlace = 1;
  232.             # check if power is on
  233.             if (bPowerIsOn == 1)
  234.             {
  235.                 upstairsAnimState = upstairsStateStarting;
  236.             }
  237.         }
  238.     }
  239.         
  240.     # check if Indy lands on ledge
  241.     if ((GetSenderRef() == musicledge) && (bPowerIsOn == 1) && (played==0))
  242.     {
  243.         played=1;
  244.         # Flourish
  245.         PlaySoundLocal(music0, 1.0, 0.0, 0x0, 0);
  246.     }
  247.     return;
  248.     
  249.     
  250.  
  251.  
  252. exited:
  253.     # check if face has been exited
  254.     if (GetSourceRef() == clock_blockb)
  255.     {
  256.         oldCollideType = GetCollideType(clock_axel);
  257.         oldMoveSize = GetThingMoveSize(clock_axel);
  258.          
  259.         if (GetSenderRef() == power_on)
  260.         {
  261.             oldCollidetype = GetCollideType(clock_axel);
  262.             SetCollideType(clock_axel, 0);
  263.             StopKey(clock_axel, clock_axelb_track, 0);
  264.             TeleportThing(clock_axel, axelPos0);
  265.             SetCollideType(clock_axel, oldCollidetype);
  266.  
  267.             call stopDownstairsAnim;
  268.             call startDownstairsAnim;
  269.             call pauseDownstairsAnim;
  270.  
  271.             PlayKey(clock_gearsb, clock_gearsbr_k, 6, 0x12, 0);
  272.             clock_axelb_track = PlayKey(clock_axel, clock_axelbr_k, 6, 0x12, 0);
  273.  
  274.             bPowerIsOn = 0;
  275.             call stopUpstairsAnim;
  276.             return;
  277.         }
  278.         else
  279.         {
  280.             call camera;
  281.             PlayKey(clock_gearsb, clock_gearsb_k, 6, 0x12, 0);
  282.             clock_axelb_track = PlayKey(clock_axel, clock_axelb_k, 6, 0x12, 0);
  283.             PlaySoundLocal(powerinit, .3, 0, 0x0000, 0);
  284.         }
  285.  
  286.         return;
  287.     }        
  288.     # is block moving off a face?
  289.     if ((GetSenderId == 1) && (GetSourceRef() == gearBlock))
  290.     {
  291.             
  292.         # is block off trigger?
  293.         if (GetSenderRef() == gearEngaged) 
  294.         {
  295.             bGearBlockInPlace = 0;
  296.             upstairsAnimState = upstairsStateStopping;
  297.         }
  298.     }
  299.     # return control to player
  300.     return;
  301.  
  302. callback:
  303.     if ((upstairsAnimState == upstairsStateStarting) && (GetParam(1) == 26))
  304.     {
  305.         call startUpstairsAnim;
  306.         upstairsAnimState = upstairsStateRunning;
  307.         return;
  308.     }
  309.  
  310.     if ((upstairsAnimState == upstairsStateRunning) && (GetParam(1) == 26))
  311.     {
  312.         PlaySoundThing(gearClunk1, gearBlock, 1, 3, 5, 0x44);
  313.     }
  314.  
  315.     
  316.     if ((upstairsAnimState == upstairsStateStopping) && (GetParam(1) == 27))
  317.     {
  318.         call stopUpstairsAnim;
  319.         upstairsAnimState = upstairsStateStopped;
  320.         return;
  321.     }
  322.     return;
  323.  
  324. startUpstairsAnim:
  325.     if (clock_houra_track == -1)
  326.         clock_houra_track = PlayKey(clock_houra,    clock_houra_k,    4, 0x10, 0);
  327.  
  328.     if (clock_hourb_track == -1)
  329.         clock_hourb_track = PlayKey(clock_hourb,    clock_hourb_k,    4, 0x10, 0);
  330.  
  331.     if (clock_mnut_track == -1)
  332.         clock_mnut_track = PlayKey(clock_mnut,    clock_mnut_k,    4, 0x10, 0);
  333.  
  334.     if (gearBlock_track == -1)
  335.         gearBlock_track = PlayKey(gearBlock,    gearBlock_k,    4, 0x10, 0);
  336.         
  337.     SendMessage(clockCog, user1);                // Send a User1 to cogs to let it know the power is on.
  338.     Global3 = 1;                                // Let other COGs in level know clock is running.
  339.     return;
  340.  
  341. stopUpstairsAnim:
  342.     StopKey(clock_houra,    clock_houra_track,    0);
  343.     StopKey(clock_hourb,    clock_hourb_track,    0);
  344.     StopKey(gearBlock,        gearBlock_track,    0);
  345.     StopKey(clock_mnut,        clock_mnut_track,    0);
  346.  
  347.     clock_houra_track    = -1;
  348.     clock_hourb_track    = -1;
  349.     clock_mnut_track    = -1;
  350.     gearBlock_track        = -1;
  351.    
  352.     if (upperLoop != -1)
  353.         StopSound(upperloop, 1.0);   
  354.     upperLoop = -1;
  355.  
  356.     SendMessage(clockCog, user0);                // Send a User0 to the cogs to let it know the power is off.
  357.     Global3 = 0;                                // Let other COGs in level know clock is stopped.
  358.  
  359.     return;
  360.  
  361. startDownstairsAnim:
  362.     clock_star_track    = PlayKey(clock_star,    clock_star_k,    4, 0x10, 0);
  363.     clock_axel_track    = PlayKey(clock_axel,    clock_axel_k,    4, 0x10, 0);
  364.     clock_armb_track    = PlayKey(clock_armb,    clock_armb_k,    4, 0x10, 0);
  365.     clock_armt_track    = PlayKey(clock_armt,    clock_armt_k,    4, 0x10, 0);
  366.     clock_leverb_track    = PlayKey(clock_leverb,    clock_leverb_k,    4, 0x10, 0);
  367.     clock_leverm_track    = PlayKey(clock_leverm,    clock_leverm_k,    4, 0x10, 0);
  368.     clock_levert_track    = PlayKey(clock_levert,    clock_levert_k,    4, 0x10, 0);
  369.     clock_padb_track    = PlayKey(clock_padb,    clock_padb_k,    4, 0x10, 0);
  370.     clock_padt_track    = PlayKey(clock_padt,    clock_padt_k,    4, 0x10, 0);
  371.     clock_wheelb_track    = PlayKey(clock_wheelb,    clock_wheelb_k,    4, 0x10, 0);
  372.     clock_wheelt_track    = PlayKey(clock_wheelt,    clock_wheelt_k,    4, 0x10, 0);
  373.  
  374.     return;
  375.  
  376. stopDownstairsAnim:
  377.     StopKey(clock_star,        clock_star_track, 0);
  378.     StopKey(clock_axel,        clock_axel_track, 0);
  379.     StopKey(clock_armb,        clock_armb_track, 0);
  380.     StopKey(clock_armt,        clock_armt_track, 0);
  381.     StopKey(clock_leverb,    clock_leverb_track, 0);
  382.     StopKey(clock_leverm,    clock_leverm_track, 0);
  383.     StopKey(clock_levert,    clock_levert_track, 0);
  384.     StopKey(clock_padb,        clock_padb_track, 0);
  385.     StopKey(clock_padt,        clock_padt_track, 0);
  386.     StopKey(clock_wheelb,    clock_wheelb_track, 0);
  387.     StopKey(clock_wheelt,    clock_wheelt_track, 0);
  388.  
  389.     CopyOrientAndPos(clock_padb_ghost, clock_padb);
  390.     CopyOrientAndPos(clock_padt_ghost, clock_padt);
  391.  
  392.     return;
  393.  
  394. pauseDownstairsAnim:
  395.     PauseKey(clock_star,    clock_star_track);
  396.     PauseKey(clock_axel,    clock_axel_track);
  397.     PauseKey(clock_armb,    clock_armb_track);
  398.     PauseKey(clock_armt,    clock_armt_track);
  399.     PauseKey(clock_leverb,    clock_leverb_track);
  400.     PauseKey(clock_leverm,    clock_leverm_track);
  401.     PauseKey(clock_levert,    clock_levert_track);
  402.     PauseKey(clock_padb,    clock_padb_track);
  403.     PauseKey(clock_padt,    clock_padt_track);
  404.     PauseKey(clock_wheelb,    clock_wheelb_track);
  405.     PauseKey(clock_wheelt,    clock_wheelt_track);
  406.  
  407.     StopSound(lowerloop, 4.0);
  408.     StopSound(lowerloop1, 4.0);
  409.         
  410.     // We've lost power, so pause the upstairs animations as well.
  411.     upstairsAnimState = upstairsStateStopping;
  412.  
  413.     return;
  414.  
  415. resumeDownstairsAnim:
  416.     ResumeKey(clock_star,    clock_star_track);
  417.     ResumeKey(clock_axel,    clock_axel_track);
  418.     ResumeKey(clock_armb,    clock_armb_track);
  419.     ResumeKey(clock_armt,    clock_armt_track);
  420.     ResumeKey(clock_leverb,    clock_leverb_track);
  421.     ResumeKey(clock_leverm,    clock_leverm_track);
  422.     ResumeKey(clock_levert,    clock_levert_track);
  423.     ResumeKey(clock_padb,    clock_padb_track);
  424.     ResumeKey(clock_padt,    clock_padt_track);
  425.     ResumeKey(clock_wheelb,    clock_wheelb_track);
  426.     ResumeKey(clock_wheelt,    clock_wheelt_track);
  427.     sleep(.5);
  428.  
  429.     lowerloop = PlaySoundThing(lowerOn, clock_wheelb, 1, 3, 25, 0x881);
  430.     lowerloop1 = PlaySoundThing(strain, clock_leverm , 1, 3, 10, 0x881);
  431.  
  432.     if (upperLoop == -1)
  433.         upperloop = PlaySoundThing(upperOn, clock_wheelt, 1, 2, 10, 0x881);
  434.     
  435.     if (bGearBlockInPlace)
  436.     {
  437.         upstairsAnimState = upstairsStateStarting;
  438.     }
  439.  
  440.     return;
  441.  
  442. Camera:
  443.  
  444.     # Show power coming on
  445.       
  446.     # Set offset camera...
  447.     StartCutscene(0);
  448.     
  449.     SetCameraLookInterp(2, 0);            # kill pan & tilt to lock on 2nd target
  450.       SetCameraPosInterp(2, 0);            # kill dolly mode too
  451.     SetCameraFocus(2, cam1spot);        # cam 2 takes over here
  452.     SetCameraSecondaryFocus(2, cam1look); #looking same place
  453.     viewangle = GetCameraFOV(); # it pays to be careful
  454.     SetCurrentCamera(2);
  455.     SetCameraFOV(viewangle, 0, 0.0); # start here anyway
  456.     SetCameraLookInterp(2, 1);             
  457.     SetCameraPosInterp(2, 1);
  458.     SetCameraInterpSpeed(2, 2.3); # about right
  459.     Sleep(0.01);
  460.     SetCameraFocus(2, offsetcam);  # slide out to new spot
  461.     SetCameraSecondaryFocus(2, offsettarg);    # slide over to new target 
  462.               
  463.     return;
  464.  
  465. ReturnControl:
  466.  
  467.     # return control to player
  468.     sleep(.5);
  469.     SetCameraLookInterp(2, 0); # kill pan & tilt mode
  470.     SetCameraPosInterp(2, 0); # kill dolly mode
  471.     SetCameraPosition(1, GetThingPos(offsetcam)); # prep to swing back to follow-cam
  472.     sleep(.01);
  473.     SetCurrentCamera(1);
  474.     
  475.     EndCutscene();
  476.     
  477. Touched:
  478.     if(getsenderref() == clock_blockb)
  479.     {
  480.         MakeCamera2LikeCamera1(cam1spot, cam1look);
  481.     }
  482.     return;                                     
  483.  
  484. end
  485.  
  486.  
  487.  
  488.